import { createSSRApp } from "vue";
import App from "./App.vue";
import store from "./store";
import initDayjs from "@/utils/init-dayjs";
import initRoute from "./utils/init-route";

import config from "@/common/config";
import mainInit from "@/common/init/mainInit";
import uiConfig from "@/common/uiconfig/index";

// #ifdef APP
// import RemoteConsole from "@/uni_modules/zui-remote-console/js_sdk/client/client.es.js";
// import devToolInit from "@/common/init/devtoolsInit";
// #endif
// #ifdef APP
// RemoteConsole({
//   // 如需在 nvue 页面中使用, 请设置为 true
//   nvue: false,
// });
// #endif

export function createApp() {
  const app = createSSRApp(App);
  initDayjs(app);
  initRoute(app);

  // #ifdef APP
  // ---- Devtools -----------------------------------------------------
  // devToolInit(app);
  // ------------------------------------------------------
  // #endif

  // 定义全局变量
  app.provide("$globalData", {
    pageChannel: {},
  });

  // 配置初始化
  config.init();
  app.provide("$config", config);

  app.use(store);

  // 配置组件库
  uiConfig(app);

  // main 初始化逻辑
  mainInit.onLoad();

  return {
    app,
  };
}
